package opreation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class FindOpreation implements IOpreation {
    @Override
    public void work(BookList booklist) {
        //System.out.println("查找图书");
        System.out.println("请输入需要查找书的名字");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int size = booklist.getUsedsize();
        for ( int i = 0; i < size; i++) {
            Book book = booklist.getBooks(i);//拿到一本书的地址
            if(book.getName().equals(name)) {
                System.out.println("找到了"+book);
                return;
            }
        }
            System.out.println("找不到"+name);
    }
}
